import { Message } from 'element-ui'

export const questionModule = async (fn, params, msg) => {
  const response = fn(params)
  await response.then(res => {
    if (res.data.id || res.data.success) {
      Message({
        message: `${msg}成功!`
      })
    } else {
      Message({
        type: 'error',
        message: `${msg}失败!`
      })
    }
  })
    .catch(() => {
      Message({
        type: 'error',
        message: '请求异常!'
      })
    })
}
